﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ProgNetComponents.Design.Designers;
using System.ComponentModel.Design;
using ProgNetDxComponents.ExtenderProviders.Browsers;

namespace ProgNetDxComponents.Design.Designers
{
    public class BrowserContainerDesigner : BaseCollectionContainerDesigner
    {
        protected override string ItemsPropName
        {
            get { return "Items"; }
        }
        public override DesignerVerbCollection Verbs
        {
            get
            {
                DesignerVerbCollection list = base.Verbs;
                list.Add(new DesignerVerb("Create Constant Class", new EventHandler(GenerateClass)));
                return list;
            }
        }
        protected BrowserContainer Container
        {
            get { return Component as BrowserContainer; }
        }

        private void GenerateClass(object sender, EventArgs e)
        {
            if (Container != null)
            {
                List<string> list = GetItems();
                string ClassName = "BrowserNames";
                string Namespace = ProgNetComponents.Constants.ProgNetConstNamespace;
                ProgNetComponents.Design.Serialization.ProjectHelper.AddConstantStringClass(Component, Namespace, ClassName, list);
            }
        }

        protected List<string> GetItems()
        {
            List<string> l = new List<string>();
            foreach (Browser d in Container.Items)
            {
                if (!l.Contains(d.Name))
                {
                    l.Add(d.Name);
                }
            }
            return l;
        }

    }
}
